<template>
  <!-- 亿请demo回复 -->
  <div class="yqContent">
    <el-header>
      <div class="main-NAV">
        <el-breadcrumb separator-class="el-icon-arrow-right">
          <el-breadcrumb-item>机油保养邀约</el-breadcrumb-item>
          <el-breadcrumb-item>回复设置</el-breadcrumb-item>
        </el-breadcrumb>
      </div>
    </el-header>

    <div class="yqMain">
      <div class="yqMain-lef">
        <div class="title">配置</div>
        <div class="rowCss bottomLine">
          <span>节点名称</span>
          <div class="inputDiv">
            <el-input v-model.trim="addObj.name" placeholder="请输入名称"></el-input>
          </div>
        </div>
        <div class="bottomLine">
          <div class="rowCss">
            <span>模式</span>
            <div class="radioCss">
              <span :class="[addObj.type == 1 ? 'active' : '']" @click="addObj.type = 1">序列排序</span>
              <span :class="[addObj.type == 2 ? 'active' : '']" @click="addObj.type = 2">编程控制</span>
            </div>
          </div>
          <div class="rowCss">
            <span>优先级</span>
            <div class="inputDiv">
              <el-input type="number" v-model.trim="addObj.lv" min="0" placeholder="请输入优先级"></el-input>
              <el-tooltip class="item" effect="dark" content="Top Center 提示文字" placement="top">
                <i class="el-icon-question" style="color: #deadad"></i>
              </el-tooltip>
            </div>
          </div>
        </div>
        <div>
          <div class="rowCss">
            <span>如果</span>
            <template>
              <el-select placeholder="请选择" v-model="addObj.select1">
                <el-option v-for="item in option1" :label="item.label" :value="item.value" :key="item.value"></el-option>
              </el-select>
            </template>
          </div>
          <div class="rowCss" style="padding: 0">
            <span class="visibilityCss">优先级</span>
            <div class="inputDiv" style="padding: 0">
              <el-select placeholder="请选择" v-model="addObj.select2">
                <el-option v-for="item in option2" :label="item.label" :value="item.value" :key="item.value"></el-option>
              </el-select>
              <el-select placeholder="请选择" v-model="addObj.select3">
                <el-option v-for="item in option3" :label="item.label" :value="item.value" :key="item.value"></el-option>
              </el-select>
              <el-select placeholder="请选择" v-model="addObj.select4">
                <el-option v-for="item in option4" :label="item.label" :value="item.value" :key="item.value"></el-option>
              </el-select>
            </div>
          </div>
          <div class="rowCss" v-show="addObj.select2 == '自定义编辑'">
            <span class="visibilityCss">优先级</span>
            <div class="inputDiv">
              <el-input type="textarea" v-model.trim="addObj.ms" placeholder="请输入"></el-input>
            </div>
          </div>
        </div>

        <div class="saveSet" @click="saveSet">发布配置</div>
      </div>
      <div class="yqMain-rig">
        <div class="Item" v-for="(item, index) in tableData" :key="item.index">
          <div class="Item-title">
            <span>{{ index + 1 }}</span>
            <div>{{ item.name }}</div>
          </div>
          <div class="Item-content Item-title">
            <span></span>
            <div>{{ item.ms || '对话式文档回答' }}</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      option1: [
        { label: '当前轮解析结果中', value: '当前轮解析结果中' },
        { label: '判断多轮对话', value: '判断多轮对话' },
      ],
      option2: [
        { label: '对话式文档问答', value: '对话式文档问答' },
        { label: '自定义编辑', value: '自定义编辑' },
      ],
      option3: [
        { label: '指定序列回答', value: '指定序列回答' },
        { label: '意图', value: '意图' },
      ],
      option4: [
        { label: '为空', value: '为空' },
        { label: '不为空', value: '不为空' },
      ],
      tableData: [],
      addObj: {
        name: '',
        type: 1,
        lv: 1,
        select1: '当前轮解析结果中',
        select2: '对话式文档问答',
        select3: '意图',
        select4: '不为空',
        ms: '',
      },
    };
  },
  methods: {
    saveSet() {
      if (!this.addObj.name) {
        this.$message.error('请输入名称');
        return;
      }
      if (this.addObj.select2 == '自定义编辑') {
        if (!this.addObj.ms) {
          this.$message.error('请输入自定义编辑内容');
          return;
        }
      }
      this.tableData.push(this.addObj);
      this.addObj = {
        name: '',
        type: 1,
        lv: 1,
        select1: '当前轮解析结果中',
        select2: '对话式文档问答',
        select3: '意图',
        select4: '不为空',
        ms: '',
      };
    },
  },
  created() {
    this.tableData = JSON.parse(localStorage.getItem('DialogueList')) || [];
  },
  beforeDestroy() {
    //vue销毁之前
    localStorage.setItem('DialogueList', JSON.stringify(this.tableData));
  },
};
</script>
<style lang="less" scoped>
.visibilityCss {
  visibility: hidden;
}
.bottomLine {
  border-bottom: 1px solid #dcdcdd;
}
.main-NAV /deep/ .el-breadcrumb__item {
  background-color: #f2f2f2 !important;
  color: #303030 !important;
  font-size: 16px !important;
  &:last-of-type .el-breadcrumb__inner {
    color: #9e0018 !important;
  }
}
.yqContent {
  height: 100%;
  display: flex;
  flex-direction: column;
}
.yqMain {
  display: flex;
  justify-content: space-between;
  height: 100%;
}
.yqMain-lef {
  min-height: 80vh;
  flex: 2;
  border: 1px solid #dcdcdd;
  margin-right: 20px;
  height: 100%;
  .title {
    height: 35px;
    font-size: 16px;
    font-weight: 600;
    color: #303030;
    line-height: 35px;
    text-align: center;
    background: #cbcbcb;
  }
}
.yqMain-rig {
  border: 1px solid #dcdcdd;
  flex: 3;
  height: 100%;
  box-sizing: border-box;
  padding: 10px;
  min-height: 80vh;
  height: 80vh;
  overflow-y: scroll;
}
.rowCss {
  display: flex;
  align-items: center;
  box-sizing: border-box;
  padding: 25px 0;
}
.rowCss > span {
  min-width: 100px;
  text-align: center;
  font-size: 14px;
  color: #303030;
}
.radioCss {
  display: flex;
  text-align: center;
  color: #9e0018;
  box-sizing: border-box;
  width: 100%;
  padding: 0 10px;
  span {
    flex: 1;
    height: 35px;
    box-sizing: border-box;
    line-height: 35px;
    border: 1px solid #dcdcdd;
    display: block;
    cursor: pointer;
  }
  .active {
    color: #fff;
    background-color: #9e0018;
  }
}
.inputDiv {
  display: flex;
  align-items: center;
  box-sizing: border-box;
  padding: 0 10px;
  width: 100%;
  flex: 1;
}
.el-input {
  /* box-sizing: border-box;
  padding: 0 10px; */
  width: 100%;
}
.el-select {
  box-sizing: border-box;
  padding: 0 10px;
  width: 100%;
}
.saveSet {
  height: 50px;
  background: #9e0018;
  color: #ffffff;
  line-height: 50px;
  text-align: center;
  box-sizing: border-box;
  margin: 20px 10px;
  cursor: pointer;
}
.Item {
  background: #f4f4f4;
  min-height: 85px;
  margin-bottom: 10px;
  padding-bottom: 10px;
}
.Item-title {
  height: 30px;
  line-height: 30px;
  font-size: 14px;
  font-weight: 500;
  color: #303030;
  display: flex;
  padding: 0 5px;
  span {
    display: block;
    width: 22px;
    height: 27px;
    background: #9e0018;
    border-radius: 0px 0px 100px 100px;
    margin-right: 10px;
    font-size: 16px;
    color: #fff;
    text-align: center;
  }
  div {
    border-bottom: 1px solid #e5e5e5;
    width: 100%;
  }
}
.Item-content {
  color: #303030;
  span {
    visibility: hidden;
  }
  div {
    border-bottom: 1px solid transparent;
    width: 100%;
  }
}
</style>
